#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define BUFF_SIZE 1024

int main()
{
    int sock_serv = socket(AF_INET, SOCK_STREAM, 0);

    struct sockaddr_in sock_addr;
    memset(&sock_addr, 0, sizeof(sockaddr));
    sock_addr.sin_family = AF_INET;
    sock_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    sock_addr.sin_port = htons(1234);
    bind(sock_serv, (struct sockaddr*)&sock_addr, sizeof(sock_addr));

    listen(sock_serv, 20);

    struct sockaddr_in clnt_addr;
    socklen_t clnt_addr_size = sizeof(clnt_addr);
    int clnt_sock = accept(sock_serv, (struct sockaddr*)&clnt_addr, &clnt_addr_size);

    char buffer[BUFF_SIZE];
    int strLen = recv(clnt_sock, buffer, BUFF_SIZE, 0);
    send(clnt_sock, buffer, strLen, 0);

    close(clnt_sock);
    close(sock_serv);

    return 0;
}